/*
 * @lc app=leetcode.cn id=222 lang=javascript
 *
 * [222] 完全二叉树的节点个数
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */

// var countNodes = function(root) {
//   if(root === null) return 0;
//   return countNodes(root.left) + countNodes(root.right) + 1;
// };

/**
 * 复习 2021-08-04
 */
// var countNodes = function(root) {
//   if(!root) return 0;
//   let ret = 0;
//   var getNode = function(root) {
//     if(!root) return;
//     ret++;
//     getNode(root.left)
//     getNode(root.right)
//   }
//   getNode(root);
//   return ret;
// }

// @lc code=end


// @after-stub-for-debug-begin
module.exports = countNodes;
// @after-stub-for-debug-end